//
//  MoreButton.swift
//  FM
//
//  Created by x on 2017/8/29.
//  Copyright © 2017年 HLB. All rights reserved.
//

import UIKit

class MoreButton: UIButton {

    
    /// 快速创建一个自定义按钮
    ///
    /// - Parameter image: <#image description#>
    /// - Returns: <#return value description#>
    class func creatButton(image:String, target:Any?, action:Selector) -> MoreButton {
        let btu = MoreButton()
        btu.setImage(UIImage.init(named: "my_right_jump"), for: UIControlState.normal);
        btu.setTitleColor(UIColor.black, for: UIControlState.normal)
        btu.translatesAutoresizingMaskIntoConstraints = false
        btu.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        
        return btu
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        titleLabel?.textColor = UIColor.black
        titleLabel?.font = UIFont.systemFont(ofSize: 14);
        titleLabel?.textAlignment = NSTextAlignment.right
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        titleLabel?.frame = CGRect.init(x: 0, y: 0, width: bounds.width-bounds.height, height: bounds.height)
        imageView?.frame = CGRect.init(x: bounds.width-15, y: bounds.height/2-7, width: 15, height: 15)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
